//
//  FirstViewController.m
//  UI_09homework
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "FirstViewController.h"
#import "MessageTelephoneView.h"

#define Width self.view.frame.size.width
#define Height self.view.frame.size.height

@interface FirstViewController ()

@end

@implementation FirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self creatMessageTele];
    
    [self creatMessTeleViews];
}

-(void)creatMessageTele{
    UISegmentedControl *segment = [[UISegmentedControl alloc]initWithItems:@[@"message", @"telephone"]];
    
    segment.frame = CGRectMake(100, 10, 150, 30);
    segment.selectedSegmentIndex = 0;
    
    self.navigationItem.titleView = segment;
    [segment release];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"people.png"] style:UIBarButtonItemStylePlain target:self action:@selector(leftAction:)];
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(rightAction:)];
    
    
}


-(void)leftAction:(UIBarButtonItem *)barButton{
    
}
-(void)rightAction:(UIBarButtonItem *)barButton{
    
}

-(void)creatMessTeleViews{
    
    NSArray *imageNames = @[@"1.png", @"2.png", @"3.png", @"4.png", @"5.png"];
    NSArray *labelTexts = @[@"cook!!", @"@@friens@@", @"**ideas**", @"giveMeBackMyMoney", @"contactToSome" ];
    for (int i = 0; i < imageNames.count; i ++) {
        
        MessageTelephoneView *mesTeleView = [[MessageTelephoneView alloc]initWithFrame:CGRectMake(10, Width / imageNames.count * (i + 1)  , Width, Height / imageNames.count) withImageName:imageNames[i] withLabelText:labelTexts[i]];
        
        [self.view addSubview:mesTeleView];
        [mesTeleView release];
        
    }
    
    
    
    
    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
